<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <title>添加</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
        content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/layui/css/layui.css">
    <link rel="stylesheet" href="/src/css/public.css">
</head>

<body>
    <div style="padding: 10px;">
        <form class="layui-form" action="" lay-filter="addForm">
            <ul class="layui-form layui-form-pane" style="margin: 15px;">
                <li class="layui-form-item">
                    <label class="layui-form-label">部门名称</label>
                    <div class="layui-input-block">
                        <input type="text" name="deptname" lay-verify="required" autocomplete="off"
                            placeholder="请输入部门名称" class="layui-input">
                    </div>
                </li>
                <li class="layui-form-item">
                    <label class="layui-form-label">部门描述</label>
                    <div class="layui-input-block">
                        <input type="text" name="deptmemo" autocomplete="off" placeholder="请输入部门描述" class="layui-input">
                    </div>
                </li>
                <li class="layui-form-item">
                    <label class="layui-form-label">部门代码</label>
                    <div class="layui-input-block">
                        <input type="text" name="deptjcdm" autocomplete="off" placeholder="请输入部门代码" class="layui-input">
                    </div>
                </li>
                <li class="layui-form-item">
                    <label class="layui-form-label">部门所在行政区划</label>
                    <div class="layui-input-block">
                        <input type="text" id="areaname" name="areaname" lay-verify="required" autocomplete="off"
                            placeholder="请选择区划" class="layui-input" style="cursor: pointer;" onkeydown="return false;"
                            oncontextmenu="return false;">
                        <input type="text" class="layui-hide" id="areanumber" name="areanumber">
                    </div>
                </li>
                <li class="layui-form-item">
                    <label class="layui-form-label">联系人</label>
                    <div class="layui-input-block">
                        <input type="text" name="lianxir" autocomplete="off" placeholder="请输入联系人" class="layui-input">
                    </div>
                </li>
                <li class="layui-form-item">
                    <label class="layui-form-label">地址</label>
                    <div class="layui-input-block">
                        <input type="text" name="dizhi" autocomplete="off" placeholder="请输入地址" class="layui-input">
                    </div>
                </li>

            </ul>


            <div style="text-align: center;">
                <button type="button" class="layui-btn" lay-submit id="YjbtnSave" lay-filter="YjbtnSave">添加</button>
            </div>
        </form>
    </div>
    <script src="/layui/layui.js"></script>
    <script>
         layui.config({
            base: '/src/'
        }).use('index', function () {
            var admin = layui.admin,
                main = layui.main,
                form = layui.form,
                setter = layui.setter,
                table = parent.layui.table;
            var $ = layui.$;
            //显示单位或部门
            $("#areaname").click(function () {
                layer.open({
                    type: 2,
                    title: '选择所属区划',
                    shadeClose: true,
                    area: ['50%', '90%'],
                    content: setter.views + 'system/area/selArea.html'
                });
            });
            //添加
            form.render().on('submit(YjbtnSave)', function (data) {
                admin.req({
                    url: 'system/dept/Add',
                    data: JSON.stringify(data.field),
                    contentType: 'application/json',
                    type: 'post',
                    done: function (res) {
                        if (res.successful) {
                            admin.msg_success(res.msg);
                            table.reload('LAY-app-dept-list');
                            parent.layer.closeAll();
                        } else {
                            admin.msg_error(res.msg);
                        }
                    }
                });
            })
        });
    </script>
</body>

</html>